
package com.lxw.multidb.controller;

import cn.tannn.jdevelops.exception.built.BusinessException;
import cn.tannn.jdevelops.result.response.ResultVO;
import com.lxw.multidb.controller.dto.LoginPassword;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
@Tag(name = "登录")
@Slf4j
public class LoginController {

    /**
     * 登录-管理端登录
     *
     * @param login LoginDTO
     * @return ResultVO
     */
    @Operation(summary = "账户密码登录")
    @PostMapping(value = "/login")
    public ResultVO<String> login(@RequestBody @Valid LoginPassword login) {
        if ("admin".equals(login.getLoginName()) && "14159".equals(login.getPassword())) {
            return ResultVO.success("登录成功");
        } else {
            throw new BusinessException("登录失败，账号或密码错误");
        }
    }
}